﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GDIScreenCapture
{
    public class Drawing
    {
        private Graphics _graphics;

        public Drawing()
        {

        }

        /// <summary>
        /// 画 截图的表示截图区域的矩形，并返回矩形区域
        /// </summary>
        /// <param name="beginPoint">鼠标按下的点</param>
        /// <param name="endPoint">鼠标当前的点</param>
        /// <param name="g">绘图工具类</param>
        public Rectangle DrawRect(Point beginPoint, Point endPoint, Graphics g)
        {
            Rectangle rect;

            int width = Math.Abs(beginPoint.X - endPoint.X);
            int height = Math.Abs(beginPoint.Y - endPoint.Y);
            if (beginPoint.X < endPoint.X)
            {
                rect = new Rectangle(beginPoint.X, beginPoint.Y, width, height);
                g.DrawRectangle(new Pen(Color.Red), rect);
            }
            else
            {
                rect = new Rectangle(endPoint.X, endPoint.Y, width, height);
                g.DrawRectangle(new Pen(Color.Red), rect);
            }
            return rect;
        }
    }
}
